import java.util.ArrayList;

public class Logic {
	private ArrayList<String> tasks;
	private boolean isEditing = false;
	private int editIndex = -1;
	Storage storage  = new Storage();
	
	enum CommandType{
		DISPLAY, ADD, DELETE, EDIT, SAVE, EXIT, INVALID
	};
	
	public CommandType determineCommandType(String command) {
		
		if(command == null) {
			throw new Error("Command type string cannot be null!");
		}
		if(command.equalsIgnoreCase("add")) {
			return CommandType.ADD;
		} else if(command.equalsIgnoreCase("display")) {
			return CommandType.DISPLAY;
		} else if(command.equalsIgnoreCase("delete")) {
			return CommandType.DELETE;
		} else if(command.equalsIgnoreCase("edit")) {
			return CommandType.EDIT;
		} else if(command.equalsIgnoreCase("save")) {
			return CommandType.SAVE;
		} else if(command.equalsIgnoreCase("exit")) {
			return CommandType.EXIT;
		} else {
			return CommandType.INVALID;
		}
	}
	
	public String executeCommand(String userInput) {
		String command = getUserCommand(userInput);
		String data = getUserData(userInput);
		
		CommandType commandType = determineCommandType(command);
		
		switch(commandType) {
		case ADD:
			return add(data);
		case DISPLAY:
			return display();
		case DELETE:
			return delete(data);
		case EDIT:
			return edit(data);
		case SAVE:
			return save();
		case EXIT:
			System.exit(0);
			break;
		case INVALID:
			return "Invalid Command";
		default:
			return "";
		}
	}
	
	// Bao Xiao
	private String getUserCommand(String userInput) {
		// TODO Auto-generated method stub
		return null;
	}
	
	// Bao Xiao
	private String getUserData(String userInput) {
		// TODO Auto-generated method stub
		return null;
	}

	private String save() {
		storage.writeToStorage();
		return null;
	}
	
	// Keith
	private String edit(String data) {
		// TODO Auto-generated method stub
		return null;
	}
	
	// Sing Yee
	private String delete(String data) {
		// TODO Auto-generated method stub
		return null;
	}
	
	// Sing Yee
	private String display() {
		// TODO Auto-generated method stub
		return null;
	}
	
	// Bao Xiao
	private String add(String data) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
